package com.guomw.report.service.service;

import java.awt.*;

public class CustomRenderer extends org.jfree.chart.renderer.category.BarRenderer {

    private Color goodColor = new Color(68, 114, 196);
    private Color badColor = new Color(255, 0, 0);

    private static final long serialVersionUID = 784630226449158436L;
    private Paint[] colors;

    public CustomRenderer(double[][] data) {
        colors = new Paint[data[0].length];
        for (int i = 0; i < data[0].length; i++) {
            colors[i] = Math.abs(data[0][i]) <= 1 ? goodColor : badColor;
        }
    }

    //每根柱子以初始化的颜色不断轮循
    public Paint getItemPaint(int i, int j) {
        return colors[j % colors.length];
    }
}